-
Notifications
You must be signed in to change notification settings - Fork 3k
Added Response Headers to Control Plane Operations #41742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Added Response Headers to Control Plane Operations #41742
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds support for retrieving response headers for control plane operations (databases and containers) on the Cosmos service, for both synchronous and asynchronous clients.
- Introduces new test cases to verify that response headers are returned for various operations.
- Adds a new get_response_headers method and initializes _response_headers in the Database and Container classes (including their async counterparts).
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
sdk/cosmos/azure-cosmos/tests/test_cosmos_responses_async.py | Added async tests for response headers on database and container operations. |
sdk/cosmos/azure-cosmos/tests/test_cosmos_responses.py | Added sync tests for response headers on database and container operations. |
sdk/cosmos/azure-cosmos/azure/cosmos/database.py | Added _response_headers initialization and get_response_headers method. |
sdk/cosmos/azure-cosmos/azure/cosmos/container.py | Added _response_headers initialization and get_response_headers method. |
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_database.py | Added _response_headers initialization and get_response_headers method for async client. |
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py | Added _response_headers initialization and get_response_headers method for async client. |
@@ -94,6 +94,7 @@ def __init__( | |||
self.id = id | |||
self.database_link: str = "dbs/{}".format(self.id) | |||
self._properties: Optional[Dict[str, Any]] = properties | |||
self._response_headers = properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If 'properties' is None, calling get_response_headers() may raise an AttributeError when attempting to use .copy(). Consider initializing _response_headers to an empty dictionary (e.g., properties or {} if properties is None).
self._response_headers = properties | |
self._response_headers = properties if properties is not None else {} |
Copilot uses AI. Check for mistakes.
@@ -104,6 +104,7 @@ def __init__( | |||
self.client_connection = client_connection | |||
self._is_system_key: Optional[bool] = None | |||
self._scripts: Optional[ScriptsProxy] = None | |||
self._response_headers = properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If 'properties' is None, calling get_response_headers() could lead to an error since .copy() would not be available. Consider defaulting _response_headers to {} when properties is None.
self._response_headers = properties | |
self._response_headers = properties if properties is not None else {} |
Copilot uses AI. Check for mistakes.
@@ -100,6 +100,7 @@ def __init__( | |||
self.id = id | |||
self.database_link = "dbs/{}".format(self.id) | |||
self._properties = properties | |||
self._response_headers = properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that _response_headers is always a dictionary. If properties is None, using .copy() in get_response_headers() will fail; consider initializing with {} as a fallback.
self._response_headers = properties | |
self._response_headers = properties if properties is not None else {} |
Copilot uses AI. Check for mistakes.
@@ -93,6 +93,7 @@ def __init__( | |||
self.container_link = "{}/colls/{}".format(database_link, self.id) | |||
self._is_system_key: Optional[bool] = None | |||
self._scripts: Optional[ScriptsProxy] = None | |||
self._response_headers = properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If 'properties' is passed as None, calling .copy() in get_response_headers() will result in an error. Consider initializing _response_headers to {} when properties is None.
self._response_headers = properties | |
self._response_headers = properties if properties is not None else {} |
Copilot uses AI. Check for mistakes.
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
This PR introduces a way to get response headers for given control plane operations on containers and databases. This is availble for both the async and sync client. Similar to #35791 for response headers at the item level.